-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct JavaFxPlayVideoAndAudio sample to synchronize audio and video… #1662
Conversation
… and prevent "dropping" of video frames Before correction, video frames may be displeyed in a quick successtion resulting in a impression of dropped frames. NOw vodeo frames are synced to the timestamp of audio playback.
Do we really need a new flag? It doesn't work with Thread.interrupt()? Also, I was under the impression that executor.submit(...).get() did the equivalent of Thread.sleep(). That's not the case? @d-a-gerashenko Would you know why it's not working? |
|
@saudet a flag is used as a different way of closing the application. After addition of I removed In the corrected code, the audio is written/played in a concurrent thread allowing display of corresponding images. The @d-a-gerashenko 1. Audio initialization did not change, it is still there, about line 61. The original example nicely shows how to decode audio and play video with sound. The correction is just to improve video/image display and use |
@jpsacha And what about sleep I see only one case I'm not sure about. Could the sleep() became the cause of gaps between sound samples? Shouldn't we use here another one thread for image displaying in time? |
@d-a-gerashenko Stopping a thread with a flag assumes that the flag is checked frequently. When we are playing video it should happen many times within a second (at least at the frame rate). If a stop has to be forced quicker am Can soundLine.addLineListener(new LineListener() {
public void update(LineEvent event) {
System.out.println("Line Event: "+ event.toString());
}
}); If the audio playback stops, for instance when buffer gets empty, there will be a
Timestamps for grabbed audio frames are ahead of grabbed image frames which allows for keeping the |
Finally:
|
1) Bring back "Thread.interrupt()" 2) Use "executor" for image branch too. 3) Enable playing videos without sound, like https://test-videos.co.uk/bigbuckbunny/mp4-h264 4) Correctly play sound in http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv
|
… and prevent "dropping" of video frames
Before correction, video frames may be displayed in a quick succession resulting in a impression of dropped frames. Now video frames are synced to the timestamp of audio playback.